package com.yuqingsong.algorithm.heap;

import java.util.Comparator;

import org.testng.annotations.Test;

/**
 * @author Administrator
 *
 */
public class HeapTest {
	
	Comparator<Integer> c = new Comparator<Integer>() {

				@Override
				public int compare(Integer o1, Integer o2) {
					return o1.compareTo(o2);
				}
	};
	

//  @Test
//  public void root() {
//    throw new RuntimeException("Test not implemented");
//  }
//
//  @Test
//  public void setRoot() {
//    throw new RuntimeException("Test not implemented");
//  }
//
//  @Test
//  public void sort() {
//    throw new RuntimeException("Test not implemented");
//  }
	
	@Test
	public void removeMax(){
		Integer[] heapArray = new Integer[]{10,2,1,3,4,5,6,7,8,9};
		Integer[] result = new Integer[]{9,8,6,7,4,5,1,2,3};
		Heap<Integer> heap = new Heap<Integer>(heapArray,c);
		heap.removeRoot();
		assert heap.equals(new Heap<Integer>(result,c));
		
	}
	
	@Test
	public void insert(){
		Integer[] heapArray = new Integer[]{9,8,6,7,4,5,1,2,3};
		Integer[] result = new Integer[]{10,9,6,7,8,5,1,2,3,4};
		Heap<Integer> heap = new Heap<Integer>(heapArray,c);
		System.out.println("before insert\r\n"+heap);
		heap.insert(new Integer(10));
		System.out.println("after insert\r\n"+heap);
		
		assert heap.equals(new Heap<Integer>(result,c));
		
	}
	
}
